package xyz.dava.sync.fm.util;

import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.HmacAlgorithm;
import cn.hutool.json.JSONUtil;
import org.apache.tomcat.util.codec.binary.Base64;

import java.nio.charset.StandardCharsets;

public class BomUtil {

    public static String getSignature(String token, Object input_params, Long signature_created) {
        String content = JSONUtil.toJsonStr(input_params) + "\n" + signature_created;
        System.out.println(content);
        return Base64.encodeBase64String(new HMac(HmacAlgorithm.HmacSHA256, token.getBytes(StandardCharsets.UTF_8)).digest(content));
    }
}
